package com.jiyang.jyandroid.test01;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/10/10.
 * 实验1-01用编程方式开发UI
 */

public class One_1Activity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Context context = this;
        LinearLayout linearLayout = new LinearLayout(context);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        TextView tv = new TextView(context);
        tv.setText("这是JAVA代码创建的布局");
        Button button = new Button(context);
        button.setText("点击加载XML布局");
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //加载XML布局
                setContentView(R.layout.activity_test01_1);
            }
        });
        setContentView(linearLayout);
        linearLayout.addView(tv);
        linearLayout.addView(button);
    }
}
